package org.lanqiao.dao;

import org.lanqiao.entity.AcActivity;
import org.lanqiao.entity.Activity;
import org.lanqiao.mapper.ActivityMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Repository;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

@Repository
public class ActivityDao {

    @Autowired
    ActivityMapper activityMapper;
    @Autowired
    RedisTemplate redisTemplate;


    /**
     * @Author 刘金渝
     * @Description //TODO
     * @Date 2019/6/12 10:12
     * @Param [id]
     * @explain
     * @return java.util.List<org.lanqiao.entity.Activity>
     */

    public Activity getActivityById(String id){
        Activity activity = activityMapper.getActivityById(id);
        return activity;
    }
    /**
     * @Author 刘金渝
     * @Description //TODO
     * @Date 2019/6/12 10:44
     * @Param []
     * @explain       获取所有地址
     * @return java.util.List<org.lanqiao.entity.Activity>
     */

    public List<Activity>getAllSite(){
        List<Activity> allSite = activityMapper.getAllSite();
        return allSite;
    }

    /**
     *功能描述 通过用户ID（userId）查询本用户所有的活动
     * @author 吴奇
     * @date 2019/5/21
     * @return java.util.List<org.lanqiao.entity.Activity>
     */
    public List<AcActivity> getActivity(String userEmail,String name){
        List<AcActivity> listActivity = activityMapper.getActivity(userEmail,name);
        return listActivity;
    }

    /**
     * @Author 刘金渝
     * @Description //TODO
     * @Date 2019/5/27 17:06
     * @Param [activity]
     * @explain       新增活动
     * @return void
     */

    public void  addActivity(Activity activity){
        activityMapper.addActivity(activity);
    }

    public List<Map> getByNameActivity(String username) {
        return activityMapper.getByNameActivity(username);
    }

    /**
     * @Author 王宇
     * @Description //TODO 根据活动名来进行活动的模糊查询
     * @Date 2019/06/03 16:17
     * @Param [activityName]
     * @return org.lanqiao.entity.Activity
     */

    public List<Activity> getActivityName(String activityName){
        return activityMapper.getActivityName(activityName);
    }

    /**
     * @Author 彭泳寒
     * @Description //TODO 根据活动id来进行活动时间查询
     */
    public Activity getActivityTime(String activityId){
        Activity activity = activityMapper.getActivityTime(activityId);
        return activity;
    }

    public void updateAc(String id,String name,String sndtime){
        activityMapper.updateAc(id,name,sndtime);
    }

    /**
     *更具活动的id进行查询活动状态
     * @param activityId
     * @return 任春旭
     */
    public Activity queryStatus(String activityId){
        Activity activity = activityMapper.queryStatus(activityId);
        return activity;
    }


    /**
     *功能描述 存入金额
     * @author 吴奇
     * @date 2019/6/19
     * @param
     * @return
     */
    public void saveMoney(String acid,double income){
        activityMapper.saveMoney(acid,income);
    }
}
